﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtaasutajad_asutaja", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtaasutajadAsutaja))]
    public class MtaasutajadAsutajaSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtaasutajadAsutaja clazz;
        
        public MtaasutajadAsutajaSerializer(IMtaasutajadAsutaja clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("asutaja_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.AsutajaId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ark");
            if (clazz.Ark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Ark))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("liik");
            if (clazz.Liik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Liik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("sissemaks");
            if (clazz.Sissemaks!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Sissemaks))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("as_tyyp");
            if (clazz.AsTyyp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsTyyp))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("eesnimi");
            if (clazz.Eesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("liignimi");
            if (clazz.Liignimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Liignimi))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("synnipaev");
            if (clazz.Synnipaev!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Synnipaev))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("riik");
            if (clazz.Riik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Riik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("valis_kood");
            if (clazz.ValisKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ValisKood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("arinimi");
            if (clazz.Arinimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Arinimi))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ark_jur");
            if (clazz.ArkJur!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.ArkJur))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("haldyks");
            if (clazz.Haldyks!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Haldyks))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("aadress");
            if (clazz.Aadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("postiind");
            if (clazz.Postiind!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Postiind))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("protsent");
            if (clazz.Protsent!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Protsent))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("volituste_kpv");
            if (clazz.VolitusteKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.VolitusteKpv))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("algus_kp");
            if (clazz.AlgusKp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKp))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("lopp_kp");
            if (clazz.LoppKp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKp))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("muutus");
            if (clazz.Muutus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Muutus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Muutus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mkuup");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Mkuup))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="asutaja_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaasutajad_asutaja>asutaja_id");
                }
                clazz.AsutajaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("asutaja_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>asutaja_id", Reader.LocalName);
            }
            if (Reader.LocalName=="ark") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Ark = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ark")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>ark", Reader.LocalName);
            }
            if (Reader.LocalName=="liik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Liik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>liik", Reader.LocalName);
            }
            if (Reader.LocalName=="sissemaks") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Sissemaks = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("sissemaks")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>sissemaks", Reader.LocalName);
            }
            if (Reader.LocalName=="as_tyyp") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("as_tyyp")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>as_tyyp", Reader.LocalName);
            }
            if (Reader.LocalName=="eesnimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>eesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="liignimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Liignimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liignimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>liignimi", Reader.LocalName);
            }
            if (Reader.LocalName=="isikukood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="synnipaev") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Synnipaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("synnipaev")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>synnipaev", Reader.LocalName);
            }
            if (Reader.LocalName=="riik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Riik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("riik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>riik", Reader.LocalName);
            }
            if (Reader.LocalName=="valis_kood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ValisKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("valis_kood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>valis_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="arinimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Arinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("arinimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>arinimi", Reader.LocalName);
            }
            if (Reader.LocalName=="ark_jur") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ArkJur = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark_jur")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>ark_jur", Reader.LocalName);
            }
            if (Reader.LocalName=="haldyks") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Haldyks = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("haldyks")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>haldyks", Reader.LocalName);
            }
            if (Reader.LocalName=="aadress") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>aadress", Reader.LocalName);
            }
            if (Reader.LocalName=="postiind") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Postiind = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("postiind")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>postiind", Reader.LocalName);
            }
            if (Reader.LocalName=="protsent") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Protsent = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("protsent")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>protsent", Reader.LocalName);
            }
            if (Reader.LocalName=="volituste_kpv") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.VolitusteKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("volituste_kpv")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>volituste_kpv", Reader.LocalName);
            }
            if (Reader.LocalName=="algus_kp") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AlgusKp = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kp")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>algus_kp", Reader.LocalName);
            }
            if (Reader.LocalName=="lopp_kp") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.LoppKp = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kp")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>lopp_kp", Reader.LocalName);
            }
            if (Reader.LocalName=="muutus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaasutajad_asutaja>muutus");
                }
                clazz.Muutus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("muutus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>muutus", Reader.LocalName);
            }
            if (Reader.LocalName=="mkuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaasutajad_asutaja>mkuup");
                }
                clazz.Mkuup = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("mkuup")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtaasutajad_asutaja>mkuup", Reader.LocalName);
            }
        }
    }
}
